package com.yhm.myfootbollshow.demos.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yhm.myfootbollshow.demos.base.ResVo;
import com.yhm.myfootbollshow.demos.entity.po.Brand;
import com.yhm.myfootbollshow.demos.service.BrandService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 品牌接口
 * @author: yhm
 * @time: 2025/4/15 12:46
 */
@RestController
@RequestMapping("yhm/brand")
public class BrandController {
    @Resource
    private BrandService brandService;

    @GetMapping("list")
    public ResVo<List<Brand>> list() {
        // 创建条件构造器
        LambdaQueryWrapper<Brand> wrapper = new LambdaQueryWrapper<>();
        // 添加status状态为1的条件
        wrapper.eq(Brand::getStatus, 1);
        // 设置查询字段id和name
        wrapper.select(Brand::getBrandId, Brand::getBrandName);
        // 执行查询
        List<Brand> list = brandService.list(wrapper);
        return ResVo.ok(list);
    }

}
